package com.robot.orders.config;

import com.github.wxpay.sdk.BaseWeChatPayConfig;
import com.github.wxpay.sdk.IWeChatPayDomain;
import com.github.wxpay.sdk.WeChatPayConstants;
import org.springframework.beans.factory.annotation.Configurable;

import java.io.InputStream;

/**
 * @author wuyunbin
 */
@Configurable
public class AppletPayConfig extends BaseWeChatPayConfig {
    private byte[] certData;

    public AppletPayConfig() throws Exception {
//        String certPath="/opt/cert.p12";
//        File file=new File(certPath);
//        InputStream inputStream=new FileInputStream(file);
//        this.certData=new byte[(int)file.length()];
//        inputStream.read(this.certData);
//        inputStream.close();
    }

    @Override
    public String getAppId() {
        return "wx17d22e764332143e";
    }

    @Override
    public String getMchId() {
        return "1580955251";
    }

    @Override
    public String getKey() {
        return "87B7CB79481F317BDE90C116CF36084B";
    }

    public String getSecret(){
        return "d1a0c3ec6e5f26f58c3ab2e953e4e645";
    }

    public String getRedirectUri() {
        return "https%3a%2f%2fmashangjie.shop";
    }

    @Override
    protected InputStream getCertStream() {
        return null;
    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return super.getHttpConnectTimeoutMs();
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return super.getHttpReadTimeoutMs();
    }

    @Override
    protected IWeChatPayDomain getWeChatPayDomain() {
        IWeChatPayDomain iWeChatPayDomain = new IWeChatPayDomain() {
            @Override
            public void report(String domain, long elapsedTimeMillis, Exception ex) {

            }

            @Override
            public DomainInfo getDomain(BaseWeChatPayConfig config) {
                return new IWeChatPayDomain.DomainInfo(WeChatPayConstants.DOMAIN_API, true);
            }
        };


        return iWeChatPayDomain;
    }

    @Override
    public boolean shouldAutoReport() {
        return super.shouldAutoReport();
    }

    @Override
    public int getReportWorkerNum() {
        return super.getReportWorkerNum();
    }

    @Override
    public int getReportQueueMaxSize() {
        return super.getReportQueueMaxSize();
    }

    @Override
    public int getReportBatchSize() {
        return super.getReportBatchSize();
    }
}
